import { check } from 'meteor/check';

if (Meteor.isServer) {
  Meteor.publish('Get.User.ById', function(id) {
    check(id, String);
    return Meteor.users.find({ 
      _id: id 
    }, {
      fields: { services: 0 }
    });
  });
}

const findUser = (id) => {
  check(id, String);

  if (Meteor.isClient) {
    Meteor.subscribe('Get.User.ById', id);
  }

  return Meteor.users.findOne({ _id: id });
};

export { findUser };
